home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / 80x0393.zip / CHIRPER.ASM < prev    next >
Assembly Source File  |  1993-03-30  |  7KB  |  228 lines

  1. ;-----------------------------------------------------------------------
  2. ; Chirper.asm - A TSR that gives each key a musical tone for audio feedback.
  3. ; This program is useful for those with visual handicaps as well as those
  4. ; that are just learning to type. After learning what each character typed
  5. ; sounds like the user will be able to audibly detect if the wrong key has
  6. ; been pressed.
  7. ;
  8. ; Released to the public domain by Garry Freemyer on 02/04/93
  9. ; Send me a note if You like it.   5829 Sawmill Road.
  10. ;                                  Paradise, CA. 95969
  11. ;                                  (916) 877-7015
  12. ;-----------------------------------------------------------------------
  13.  
  14.  
  15. cseg    segment    para    public 'code'
  16.         assume cs:cseg
  17.         org 100h
  18.  
  19. start:  jmp initialize
  20.  
  21.   old9_hndlr    label dword     ;old int 9h handler
  22.   old9_off      dw      ?
  23.   old9_seg      dw      ?
  24.   notes         dw      0
  25.                 dw      18356
  26.                 dw      17292
  27.                 dw      16344
  28.                 dw      15495
  29.                 dw      14550
  30.                 dw      13714
  31.                 dw      12969
  32.                 dw      12175
  33.                 dw      11472
  34.                 dw      10847
  35.                 dw      10198
  36.                 dw       9700
  37.                 dw       9108
  38.                 dw       8584
  39.                 dw       8116
  40.                 dw       7648
  41.                 dw       7231
  42.                 dw       6818
  43.                 dw       6449
  44.  
  45.                 dw       6087
  46.                 dw       5736
  47.                 dw       5423
  48.                 dw       5120
  49.                 dw       4830
  50.                 dw       4554
  51.                 dw       4307
  52.                 dw       4058
  53.                 dw       3836
  54.                 dw       3615
  55.                 dw       3418
  56.                 dw       3224
  57.                 dw       3043
  58.                 dw       2875
  59.                 dw       2711
  60.                 dw       2560
  61.                 dw       2415
  62.                 dw       2281
  63.                 dw       2153
  64.                 dw       2032
  65.                 dw       1918
  66.                 dw       1810
  67.                 dw       1709
  68.                 dw       1612
  69.                 dw       1521
  70.                 dw       1435
  71.                 dw       1355
  72.                 dw       1280
  73.                 dw       1207
  74.                 dw       1140
  75.                 dw       1075
  76.                 dw       1015
  77.                 dw        959
  78.                 dw        898
  79.                 dw       1709
  80.                 dw        854
  81.                 dw        806
  82.                 dw        760
  83.                 dw      65535   ;Caps Lock,
  84.                 dw        718
  85.                 dw        677
  86.                 dw        639
  87.                 dw        604
  88.                 dw        570
  89.                 dw        538
  90.                 dw        507
  91.                 dw        479
  92.                 dw        452
  93.                 dw        427
  94.                 dw        403
  95.                 dw        380
  96.                 dw        359
  97.                 dw        338
  98.                 dw        319
  99.                 dw        301
  100.                 dw        285
  101.                 dw        268
  102.                 dw        253
  103.                 dw        239
  104.                 dw        225
  105.                 dw        213
  106.                 dw        201
  107.                 dw        189
  108.                 dw        179
  109.                 dw        169
  110.                 dw        160
  111.                 dw        151
  112.                 dw        403
  113.                 dw        380
  114.  
  115.   ax_           dw      ?
  116.   bx_           dw      ?
  117.   scancode      db      ?
  118.   toggle        db      1       ;turns program on or off. 1 = on.
  119.   load_msg      db      0ah,0dh,"Chirper installed! Toggle: SysRq or Alt-SysRq for 101 Keyboard.",0ah,0dh
  120.                 db      "Toggle = SysRq.",10,13
  121.                 db      "By Garry Freemyer-916-877-7015 U.S. (Freeware)",0ah,0dh,"$"
  122.  
  123.   ;*************************************************************************
  124.   ;New handler for int 9h (keyboard hardware interrupt)
  125.   ;*************************************************************************
  126.  
  127.   new9_hndlr    proc
  128.     mov ax_,ax                  ;save ax register.
  129.     xor ax,ax                   ;zero ax register.
  130.     in al,60h                   ;get scancode.
  131.     mov scancode,al             ;store scancode.
  132.     mov ax,ax_
  133.     pushf                       ;simulate int
  134.     call  old9_hndlr
  135.     xor ax,ax
  136.  
  137.     mov al,scancode            ;ignore caps lock key.
  138.     cmp al,3ah
  139.     je exit_9
  140.  
  141.     cmp al,54h
  142.                 ;has sys req been pressed?
  143.     jne continue
  144.  
  145.     mov al,toggle
  146.     xor al,1                   ;toggle toggle
  147.     mov toggle,al
  148.     cmp al,0
  149.     je nosound                 ;turn sound off too when turning program off.
  150.  
  151. continue:
  152.     mov al,toggle              ;test status of toggle.
  153.     cmp al,0
  154.     je  exit_9                 ;if program off skip sound routines.
  155.  
  156.     mov al,scancode            ;get scancode.
  157.     cmp al,58h
  158.     ja nosound                 ;turn sound off when key is released.
  159.  
  160.     mov bx_,bx                 ;save bx
  161.     xor bx,bx                  ;zero bx
  162.     add al,al
  163.     mov bx,notes
  164.     add ax,bx                  ;ax = vector address into notes array.
  165.     mov bx,ax
  166.     mov al,0b6h                ;turn on sound
  167.     out 43h,al
  168.     mov ax,notes[bx];
  169.     out 42h,al
  170.     mov al ,ah
  171.     out 42h,al
  172.     in al,61h
  173.     or al,3
  174.     out 61h,al
  175.     mov bx,bx_
  176.     jmp exit_9
  177.  
  178. nosound:                        ;turn off sound, key is released.
  179.      in al,61h
  180.      and al,252
  181.      out 61h,al
  182.  
  183. exit_9:
  184.     mov ax,ax_
  185.     iret
  186.   new9_hndlr    endp
  187.  
  188. last_byte   db   "$"
  189.  
  190. ;------------------------------------------------------------------------
  191. ; Initialization procedure
  192. ;------------------------------------------------------------------------
  193.  
  194.   initialize    proc    near
  195.   assume        ds:cseg         ;variables in this segment
  196.  
  197.  
  198.   ;Insert new handlers into interrupt chain
  199.   ;
  200.     mov ax,cs
  201.     mov ds,ax
  202.  
  203.     mov ax,3509h                ;get interrupt 9 vector
  204.     int  21h
  205.     mov  old9_off,bx
  206.     mov  old9_seg,es
  207.  
  208.     mov  ax,2509h
  209.     mov  dx,offset new9_hndlr
  210.     int  21h
  211.  
  212.   ;Display message, then terminate but stay resident
  213.   ;
  214.     mov  dx,offset load_msg
  215.     mov  ah,9
  216.     int  21h
  217.  
  218.   ;amount of memory to retain in dx
  219.     mov  dx,(offset last_byte - offset cseg + 15)
  220.     mov  cl,4
  221.     shr  dx,cl                  ;convert to paragraphs
  222.     mov  ax,3100h               ;TSR function
  223.     int  21h
  224.   initialize    endp
  225.   ;
  226.   cseg          ends
  227.     end         start           ;end of program
  228.